import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

void alertBB(BuildContext context, String alertFieldName,
    {String alert = "提示", String submit = "提交"}) {
  showDialog<Null>(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context) {
      return CupertinoAlertDialog(
        title: Text(alert),
        content: Text('$alertFieldName'),
        actions: <Widget>[
          TextButton(
            child: Text(submit),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
        ],
      );
    },
  );
}

void alertByCallBackBB(
    BuildContext context, String alertFieldName, Function call,
    {String alert = "提示", String submit = "提交"}) {
  showDialog<Null>(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context) {
      return CupertinoAlertDialog(
        title: Text(alert),
        content: Text('$alertFieldName'),
        actions: <Widget>[
          TextButton(
            child: Text(submit),
            onPressed: () {
              Navigator.of(context).pop();
              call();
            },
          ),
        ],
      );
    },
  );
}

void TwoChooseByCallBackBB(
    BuildContext context, String alertFieldName, Function call,
    {String alert = "提示", String submit = "提交", String cancle = "取消"}) {
  showDialog<Null>(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext context) {
      return CupertinoAlertDialog(
        title: Text(alert),
        content: Text('$alertFieldName'),
        actions: <Widget>[
          TextButton(
            child: Text(cancle),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          TextButton(
            child: Text(submit),
            onPressed: () {
              Navigator.of(context).pop();
              call();
            },
          ),
        ],
      );
    },
  );
}

Future<void> alertTwoChooseBB(
    BuildContext context, String one, String two, Function(int) call,
    {String cancle = "取消"}) async {
  await showModalBottomSheet(
      context: context,
      backgroundColor: Colors.transparent,
      builder: (context) {
        return Container(
          height: 180,
          child: Column(
            children: <Widget>[
              Container(
                height: 50,
                width: double.infinity,
                margin: EdgeInsets.only(left: 10, right: 10),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(10),
                        topRight: Radius.circular(10))),
                child: TextButton(
                  style: TextButton.styleFrom(
                    textStyle: const TextStyle(
                        fontSize: 13), //nas replace by floatButton
                  ),
                  child: Text(
                    one,
                    style: TextStyle(color: Colors.black),
                  ),
                  onPressed: () async {
                    Navigator.pop(context);
                    call(1);
                  },
                ),
              ),
              Container(
                width: double.infinity,
                height: 1,
                color: Colors.grey,
                margin: EdgeInsets.only(left: 10, right: 10),
              ),
              Container(
                height: 50,
                width: double.infinity,
                margin: EdgeInsets.only(left: 10, right: 10),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.only(
                        bottomLeft: Radius.circular(10),
                        bottomRight: Radius.circular(10))),
                child: TextButton(
                  style: TextButton.styleFrom(
                    textStyle: const TextStyle(
                        fontSize: 13), //nas replace by floatButton
                  ),
                  child: Text(
                    two,
                    style: TextStyle(color: Colors.black),
                  ),
                  onPressed: () async {
                    Navigator.pop(context);
                    call(2);
                  },
                ),
              ),
              Container(
                height: 50,
                width: double.infinity,
                margin: EdgeInsets.all(10),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.all(
                      Radius.circular(8),
                    )),
                child: TextButton(
                  style: TextButton.styleFrom(
                    textStyle: const TextStyle(
                        fontSize: 13), //nas replace by floatButton
                  ),
                  child: Text(
                    cancle,
                    style: TextStyle(color: Colors.black),
                  ),
                  onPressed: () {
                    Navigator.pop(context);
                  },
                ),
              ),
            ],
          ),
        );
      });
}
